package com.ys.controller.web.administration;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ys.entity.storage.TccAllocate;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import com.bo.vo.W;
import com.ys.entity.administration.AdmUseSignetApply;
import com.ys.service.sys.CommonApiService;

@Controller
@RequestMapping("/web/administration/webAdmUseSignetApplyController")
public class WebAdmUseSignetApplyController {
	private static final Logger logger = LoggerFactory.getLogger(WebAdmUseSignetApplyController.class);

	public static Long MENU_ID = 10166L;

	@Autowired
	private CommonApiService<AdmUseSignetApply> commonService;


	/*
	 * 新增
	 */
	@RequiresPermissions("admUseSignetApply:add")
	@GetMapping("/toAdd")
	public String toAdd(Model model, HttpServletRequest request, HttpServletResponse response){

		AdmUseSignetApply entity = new AdmUseSignetApply();
		try {
			String bid = commonService.getCommonNextBid(MENU_ID);
			entity.setBid(bid);
			return commonService.toAdd(model, entity, MENU_ID, null, null);
		} catch (Exception e) {
			logger.error("印章申请表新增页面出错：",e.getMessage(),e);
			return W.error(model, e.getMessage());
		}
	}

	/*
	 * 编辑
	 */
	@GetMapping("/toEdit")
	public String toEdit(Model model, HttpServletRequest request, HttpServletResponse response,
						 String bid){
		if (bid == null || bid.length() == 0) {
			return com.ys.vo.W.error(model, "单号不能为空");
		}

		AdmUseSignetApply entity = new AdmUseSignetApply().setBid(bid).queryFirst();
		try {
			return commonService.toEdit(model, entity.getId(), new AdmUseSignetApply(), MENU_ID, null, null);
		} catch (Exception e) {
			logger.error("印章申请表编辑页面出错：",e.getMessage(),e);
			return W.error(model, e.getMessage());
		}
	}




}



